package com.xiaoshuidi.cloud.module.contract.dal.mysql.contract;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaoshuidi.cloud.framework.mybatis.core.mapper.BaseMapperX;
import com.xiaoshuidi.cloud.module.contract.controller.admin.contract.vo.ContractTenantInformationRepVO;
import com.xiaoshuidi.cloud.module.contract.controller.admin.contract.vo.company.CompanyContractExcelReqVO;
import com.xiaoshuidi.cloud.module.contract.controller.admin.contract.vo.company.CompanyContractListRespVO;
import com.xiaoshuidi.cloud.module.contract.controller.admin.contract.vo.company.CompanyContractPageReqVO;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.contract.CompanyContractDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 企业合同 Mapper
 *
 * @author red
 */
@Mapper
public interface CompanyContractMapper extends BaseMapperX<CompanyContractDO> {
    //用mybatis-plus方法查无法查出roomids字段信息
    CompanyContractDO selectCompanyContractById(Long id);

    List<CompanyContractDO> selectCompanyContractByIds(@Param("ids") List<Long> ids);

    Page<CompanyContractListRespVO> pageCompanyContractList(Page<CompanyContractListRespVO> page,
                                                            @Param("pageReqVO") CompanyContractPageReqVO pageReqVO);

    List<CompanyContractListRespVO> selectExportCompanyContractList(@Param("exportReqVO") CompanyContractExcelReqVO exportReqVO);

    @Select("select company_name from contract_company where id =#{id}")
    String getCompanyNameById(Long id);

    ContractTenantInformationRepVO getRoomData(@Param("id") Long id);

    @Select({"select * from contract_company where room_ids LIKE concat('%',#{roomId},'%') limit 1"})
    CompanyContractListRespVO queryByRoomId(Long roomId);
}
